package ibmetp.mis.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Map;
import java.util.TreeMap;
/**
 * 统计信息
 * @author BIN
 *
 */
public class CommonDao {
	protected Connection conn;
	
	public Map<String,Integer>  getDeptStatics()
	{
		Map<String,Integer> map=new TreeMap();
		conn=DBUtil.getConnection();
		
		String sql="Select Count(*) TOTAL,Dept_Name From(Select * From Bas_T_User U,Bas_T_Dept D Where U.Dept_Id=D.Dept_Id(+)) Group By Dept_Name";
		System.out.println(sql);
	
		PreparedStatement ps;
		
	
		try{
			ps=conn.prepareStatement(sql);
			
			ResultSet rs=ps.executeQuery();
			while(rs!=null && rs.next())
			{ 
				if(rs.getString("DEPT_NAME")==null)
				{
					map.put("----", rs.getInt("TOTAL"));
				}
				else map.put(rs.getString("DEPT_NAME"), rs.getInt("TOTAL"));
			}
			ps.close();
			conn.close();			
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		
		
		
		return map;
	}
}
